/* Imports...feel free to add here as needed */
const commandHeader = `
const {Clutter, Gio, GLib, GObject, Meta, Shell, St} = imports.gi;
- const Main = imports.ui.main;
+ const Main = await imports.ui.main;
/* Utility functions...we should probably be able to use these
* in the shell core code too. */
const it = Main.lookingGlass.getIt();
const r = Main.lookingGlass.getResult.bind(Main.lookingGlass);
`;
+const AsyncFunction = async function () {}.constructor;
const HISTORY_KEY = 'looking-glass-history';
// Time between tabs for them to count as a double-tab event
// Ensure we don't get newlines in the command; the history file is
// newline-separated.
text = text.replace('\n', ' ');
- this._evaluate(text);
+ this._evaluate(text).catch(logError);
return true;
});
}
}
- _evaluate(command) {
+ async _evaluate(command) {
command = this._history.addItem(command); // trims command
if (!command)
return;
let resultObj;
try {
- resultObj = Function(fullCmd)();
+ resultObj = await AsyncFunction(fullCmd)();
} catch (e) {
resultObj = `<exception ${e}>`;
}